package com.docjohnson.pamphlet.dialogs;

import android.app.Dialog;
import android.content.Context;
import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;
import android.widget.MediaController;
import android.widget.VideoView;
import com.docjohnson.pamphlet.R;

public class VideoViewDialog extends Dialog implements View.OnClickListener {

    Context mContext;

    public VideoViewDialog(Context context) {
        super(context);
        setCancelable(false);
        setContentView(R.layout.videoview);
        mContext = context;
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        VideoView myVideoView = (VideoView)findViewById(R.id.videoView);
        myVideoView.setVideoPath("http://commonsware.com/misc/test2.3gp");
        MediaController mc = new MediaController(mContext);
        mc.setMediaPlayer(myVideoView);
        mc.setAnchorView(myVideoView);
        myVideoView.setMediaController(mc);
        myVideoView.requestFocus();
        myVideoView.start();

        ((ImageView)findViewById(R.id.closeVideoViewId)).setOnClickListener(this);

    }

    @Override
    public void onClick(View view) {
        switch (view.getId()){
            case R.id.closeVideoViewId:
                dismiss();
                break;
            default:
                break;
        }
    }
}
